<?php
/**
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       Cake.View.Layouts
 * @since         CakePHP(tm) v 0.10.0.1076
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

$cakeDescription = __d('cake_dev', 'Tfp V1.0');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php echo $this->Html->charset(); ?>
	<title>
		Georefsys v1:
		<?php echo $title_for_layout; ?>
	</title>
	<?php
		echo $this->Html->meta('icon');

		//echo $this->Html->css('cake.generic');
		//echo $this->Html->css('umstyle');

		echo $this->fetch('meta');
		echo $this->fetch('css');
		echo $this->fetch('script');
	?>
	<style type="text/css">
        html, body {
        height: 100%;
        margin: 0;
        font-family: verdana;
        }
        iframe{
        border:0px;
		min-width: 500px;
        max-height: 700px;
		min-height: 600px;

        }
        #map-canvas {
        width: 100%;
        height: 100%;
        }
        .iwContent{width:400px;}
	html { height: 100% }
	body { height: 100%; margin: 0; padding: 0 }
      	#map_canvas { height: 100% }



    </style>
          <?php $all_events_js = $this->Html->url(array(
		"controller" => "events",
		"action" => "all_events_js"	));
	  ?>
     
	<?php echo $this->Html->script('jquery-1.7.2.min');?>
    <?php echo $this->Html->script('fancybox');?>
    <?php echo $this->Html->css('fancybox'); ?>
    
    <script type="text/javascript" src="<?php echo $all_events_js; ?>?<?php echo rand(1,5000)?>"></script>
    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">

      var contentString = 'Ha ocurrido un error';
      
        var infowindow = new google.maps.InfoWindow({
            content: contentString
        });

      var map;
      var markers = [];
	  var markers2 = [];

      function initialize() {
        var haightAshbury = new google.maps.LatLng(4.636215392993458,-74.0837287902832);
        var mapOptions = {
          zoom: 17,
          center: haightAshbury,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        map = new google.maps.Map(document.getElementById('map-canvas'),
            mapOptions);

        google.maps.event.addListener(map, 'click', function(event) {
          addMarker(event.latLng);
        });
		
		google.maps.event.addListener(infowindow, 'closeclick', function() {  
			window.location.reload();
		});  
		
		function addMarkerRe(lat,lng,id,icon) {
		var location = new google.maps.LatLng(lat,lng);
        marker = new google.maps.Marker({
          position: location,
          map: map,
		  icon: "/cake/img/icons/"+icon

        });
		
        markers2.push(marker);
		var idt=id.toString();
		
		google.maps.event.addListener(marker, 'click', function() {
		infowindow.setContent('<iframe style="height:450px" src="../events/view_public_event/'+idt+'" frameborder="0" scrolling="auto" ></iframe>');

 		 infowindow.open(map, this);
		});
      }
	  
	  
	
		
		for(var i in geoPoints)
		{
    		addMarkerRe(geoPoints[i][2],geoPoints[i][3],geoPoints[i][0],geoPoints[i][1])
		}
		
		
		

		<?php $link = $this->Html->url(array(
		"controller" => "places",
		"action" => "public_place_options"	));
		?>
	  
      function addMarker(location) {
        deleteOverlays();
        marker = new google.maps.Marker({
          position: location,
          map: map,
        });
        markers.push(marker);
		infowindow.setContent('<iframe src="<?php echo $link; ?>/'+location.lat()+'/'+location.lng()+'" frameborder="0" scrolling="auto" ></iframe>');
        infowindow.open(map,marker);
             
      }

      function setAllMap(map) {
        for (var i = 0; i < markers.length; i++) {
          markers[i].setMap(map);
        }
      }

       function clearOverlays() {
        setAllMap(null);
      }

       function showOverlays() {
        setAllMap(map);
      }

       function deleteOverlays() {
        clearOverlays();
        markers = [];
      }}
	  
		
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
<?php if($_SESSION["visitado"]!=true){ ?>
<script type="text/javascript">
		$(document).ready(function () {
        $.fancybox({
            'autoScale': false,
            'transitionIn': 'fade',
            'transitionOut': 'fade',
            'type': 'iframe',
            'href': '../bienvenido.php'
        });
});
	</script>
<?php $_SESSION["visitado"]=true ;
}
?>
</head>
<body>
<div id="map-canvas">
</div>
</html>


